home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 January / macformat-020.iso / Shareware City / Developers / apps.to.go / DTS.StyleChat / WindowDialog.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-05-18  |  9.1 KB  |  394 lines  |  [TEXT/MPS ]

  1. /*
  2. ** Apple Macintosh Developer Technical Support
  3. **
  4. ** File:        WindowDialog.c
  5. ** Written by:    Eric Soldan
  6. **
  7. ** Copyright © 1990-1993 Apple Computer, Inc.
  8. ** All rights reserved.
  9. */
  10.  
  11. /* You may incorporate this sample code into your applications without
  12. ** restriction, though the sample code has been provided "AS IS" and the
  13. ** responsibility for its operation is 100% yours.  However, what you are
  14. ** not permitted to do is to redistribute the source as "DSC Sample Code"
  15. ** after having made changes. If you're going to re-distribute the source,
  16. ** we require that you make it clear in the source that the code was
  17. ** descended from Apple Sample Code, but that you've made changes. */
  18.  
  19.  
  20.  
  21. /*****************************************************************************/
  22.  
  23.  
  24.  
  25. #include "App.h"            /* Get the application includes/typedefs, etc.    */
  26. #include "App.defs.h"        /* Get various application definitions.            */
  27. #include "App.protos.h"        /* Get the prototypes for application.            */
  28.  
  29. #ifndef __ERRORS__
  30. #include <Errors.h>
  31. #endif
  32.  
  33. #ifndef __UTILITIES__
  34. #include "Utilities.h"
  35. #endif
  36.  
  37.  
  38.  
  39. /*****************************************************************************/
  40.  
  41.  
  42.  
  43. extern RgnHandle    gCursorRgn;                /* We handle cursors here, so we need */
  44. extern CursPtr        gCursorPtr;                /* to know about these things. */
  45.                                             /* Above are DTS.Lib..framework globals. */
  46.  
  47. extern short        gDialogErr;                /* Error numbers to be displayed in   */
  48.                                             /* a dialog window of type 'ERR#' are */
  49.                                             /* passed in this way.                  */
  50.  
  51. static short    gCtlNum;
  52.  
  53.  
  54.  
  55. /*****************************************************************************/
  56. /*****************************************************************************/
  57.  
  58.  
  59.  
  60. /* •• You don't call this.  DTS.Lib..framework does for appropriate document type(s). •• */
  61. /* See CalcFrameRgn() for info. */
  62.  
  63. #pragma segment TheDoc
  64. void    DialogCalcFrameRgn(FileRecHndl frHndl, WindowPtr window, RgnHandle rgn)
  65. {
  66. #ifndef __MWERKS__
  67. #pragma unused (frHndl, window, rgn)
  68. #endif
  69. }
  70.  
  71.  
  72.  
  73. /*****************************************************************************/
  74.  
  75.  
  76.  
  77. /* •• You don't call this.  DTS.Lib..framework does for appropriate document type(s). •• */
  78. /* See ContentClick() for info. */
  79.  
  80. #pragma segment TheDoc
  81. void    DialogContentClick(WindowPtr window, EventRecord *event, Boolean firstClick)
  82. {
  83. #ifndef __MWERKS__
  84. #pragma unused (firstClick)
  85. #endif
  86.  
  87.     short            cnum, action;
  88.     ControlHandle    ctl;
  89.  
  90.     gCtlNum = cnum = IsCtlEvent(window, event, &ctl, &action);
  91.     if ((cnum == -1) || (cnum == -2))
  92.         if (GetButtonVariant(ctl) == pushButProc)
  93.             DisposeOneWindow(window, kClose);
  94.  
  95.     return;
  96. }
  97.  
  98.  
  99.  
  100. /*****************************************************************************/
  101.  
  102.  
  103.  
  104. /* •• You don't call this.  DTS.Lib..framework does for appropriate document type(s). •• */
  105. /* See ContentKey() for info. */
  106.  
  107. #pragma segment TheDoc
  108. Boolean    DialogContentKey(WindowPtr window, EventRecord *event, Boolean *passThrough)
  109. {
  110. #ifndef __MWERKS__
  111. #pragma unused (passThrough)
  112. #endif
  113.  
  114.     short            cnum, action;
  115.     ControlHandle    ctl;
  116.  
  117.     gCtlNum = cnum = IsCtlEvent(window, event, &ctl, &action);
  118.     if ((cnum == -1) || (cnum == -2)) {
  119.         if (GetButtonVariant(ctl) == pushButProc) {
  120.             DisposeOneWindow(window, kClose);
  121.             return(true);
  122.         }
  123.     }
  124.  
  125. #if DEV_VERSION
  126.     if ((event->message & charCodeMask) == (unsigned char)'≥') {
  127.         if ((event->modifiers & (optionKey | cmdKey)) == (optionKey | cmdKey)) {
  128.             gCtlNum = -2;
  129.             DisposeOneWindow(window, kClose);
  130.         }
  131.     }
  132. #endif
  133.  
  134.     return(true);
  135. }
  136.  
  137.  
  138.  
  139. /*****************************************************************************/
  140.  
  141.  
  142.  
  143. /* •• You don't call this.  DTS.Lib..framework does for appropriate document type(s). •• */
  144. /* See DrawFrame() for info. */
  145.  
  146. #pragma segment TheDoc
  147. void    DialogDrawFrame(FileRecHndl frHndl, WindowPtr window, Boolean activate)
  148. {
  149.     MoveTo(0, (*frHndl)->fileState.topSidebar - 1);
  150.     LineTo((*frHndl)->fileState.leftSidebar - 1 - 16384, (*frHndl)->fileState.topSidebar - 1);
  151.     LineTo((*frHndl)->fileState.leftSidebar - 1 - 16384, 16383);
  152.  
  153.     BeginFrame(window);
  154.     DoDrawControls(window, activate);
  155.     EndFrame(window);
  156. }
  157.  
  158.  
  159.  
  160. /*****************************************************************************/
  161.  
  162.  
  163.  
  164. /* •• You don't call this.  DTS.Lib..framework does for appropriate document type(s). •• */
  165. /* See FreeDocument() for info. */
  166.  
  167. #pragma segment TheDoc
  168. OSErr    DialogFreeDocument(FileRecHndl frHndl)
  169. {
  170.     return(DefaultFreeDocument(frHndl));
  171. }
  172.  
  173.  
  174.  
  175. /*****************************************************************************/
  176.  
  177.  
  178.  
  179. /* •• You don't call this.  DTS.Lib..framework does for appropriate document type(s). •• */
  180. /* See FreeWindow() for info. */
  181.  
  182. #pragma segment TheDoc
  183. OSErr    DialogFreeWindow(FileRecHndl frHndl, WindowPtr window)
  184. {
  185. #ifndef __MWERKS__
  186. #pragma unused (frHndl, window)
  187. #endif
  188.  
  189. /* For dialogs that need to keep their info before getting dismissed:
  190. **   Check gCtlNum to see what control caused dialog dismissal.
  191. **     -1: Default button.
  192. **     -2: Cancel button.
  193. **   If you determine that the dialog shouldn't be dismissed after all, then
  194. **   return an error.
  195. */
  196.  
  197.     return(noErr);
  198. }
  199.  
  200.  
  201.  
  202. /*****************************************************************************/
  203.  
  204.  
  205.  
  206. /* •• You don't call this.  DTS.Lib..framework does for appropriate document type(s). •• */
  207. /* See ImageDocument() for info. */
  208.  
  209. #pragma segment TheDoc
  210. OSErr    DialogImageDocument(FileRecHndl frHndl)
  211. {
  212. #ifndef __MWERKS__
  213. #pragma unused (frHndl)
  214. #endif
  215.  
  216.     WindowPtr    curPort;
  217.  
  218.     GetPort(&curPort);
  219.     DoDrawControls(curPort, false);            /* Draw the content controls. */
  220.  
  221.     return(noErr);
  222. }
  223.  
  224.  
  225.  
  226. /*****************************************************************************/
  227.  
  228.  
  229.  
  230. /* •• You don't call this.  DTS.Lib..framework does for appropriate document type(s). •• */
  231. /* See InitContent() for info. */
  232.  
  233. #pragma segment TheDoc
  234. OSErr    DialogInitContent(FileRecHndl frHndl, WindowPtr window)
  235. {
  236.     OSErr            err;
  237.     OSType            sftype;
  238.     ControlHandle    ctl;
  239.     Str255            pstr;
  240.  
  241.     sftype = (*frHndl)->fileState.sfType;
  242.     err = AddControlSet(window, sftype, kwStandardVis, 0, 0, nil);
  243.     if (sftype == 'ERR#') {
  244.         CNum2Ctl(window, 100, &ctl);
  245.         if (ctl) {
  246.             CTEGetPStr(ctl, pstr);
  247.             pcatdec(pstr, gDialogErr);
  248.             gDialogErr = noErr;
  249.             CTESetPStr(ctl, pstr);
  250.         }
  251.     }
  252.  
  253.     return(err);
  254. }
  255.  
  256.  
  257.  
  258. /*****************************************************************************/
  259.  
  260.  
  261.  
  262. /* •• You don't call this.  DTS.Lib..framework does for appropriate document type(s). •• */
  263. /* See ResizeContent() for info. */
  264.  
  265. #pragma segment TheDoc
  266. void    DialogResizeContent(WindowPtr window, short oldh, short oldv)
  267. {
  268. #ifndef __MWERKS__
  269. #pragma unused (window, oldh, oldv)
  270. #endif
  271. }
  272.  
  273.  
  274.  
  275. /*****************************************************************************/
  276.  
  277.  
  278.  
  279. /* •• You don't call this.  DTS.Lib..framework does for appropriate document type(s). •• */
  280. /* See ScrollFrame() for info. */
  281.  
  282. #pragma segment TheDoc
  283. void    DialogScrollFrame(FileRecHndl frHndl, WindowPtr window, long dh, long dv)
  284. {
  285. #ifndef __MWERKS__
  286. #pragma unused (frHndl, window, dh, dv)
  287. #endif
  288. }
  289.  
  290.  
  291.  
  292. /*****************************************************************************/
  293.  
  294.  
  295.  
  296. /* •• You don't call this.  DTS.Lib..framework does for appropriate document type(s). •• */
  297. /* See UndoFixup() for info. */
  298.  
  299. #pragma segment TheDoc
  300. void    DialogUndoFixup(FileRecHndl frHndl, Point contOrg, Boolean afterUndo)
  301. {
  302. #ifndef __MWERKS__
  303. #pragma unused (frHndl, contOrg, afterUndo)
  304. #endif
  305.  
  306.     /* See DTS.Draw for an example of what you might do here. */
  307. }
  308.  
  309.  
  310.  
  311. /*****************************************************************************/
  312.  
  313.  
  314.  
  315. /* •• You don't call this.  DTS.Lib..framework does for appropriate document type(s). •• */
  316. /* See WindowCursor() for info. */
  317.  
  318. #pragma segment TheDoc
  319. Boolean    DialogWindowCursor(FileRecHndl frHndl, WindowPtr window, Point globalPt)
  320. {
  321. #ifndef __MWERKS__
  322. #pragma unused (frHndl, window, globalPt)
  323. #endif
  324.  
  325.     /* For examples of applications that have non-arrow cursor regions,
  326.     ** see DTS.Chat and DTS.Draw. */
  327.  
  328.     DoSetCursor(&qd.arrow);
  329.     return(true);
  330. }
  331.  
  332.  
  333.  
  334. /*****************************************************************************/
  335.  
  336.  
  337.  
  338. /* •• You don't call this.  DTS.Lib..framework does for appropriate document type(s). •• */
  339. /* See WindowGoneFixup() for info. */
  340.  
  341. #pragma segment TheDoc
  342. void    DialogWindowGoneFixup(WindowPtr window)
  343. {
  344. #ifndef __MWERKS__
  345. #pragma unused (window)
  346. #endif
  347. }
  348.  
  349.  
  350.  
  351. /*****************************************************************************/
  352. /*****************************************************************************/
  353. /*****************************************************************************/
  354.  
  355.  
  356.  
  357. /* •• You don't call this.  DTS.Lib..framework does for appropriate document type(s). •• */
  358. /* See AdjustMenuItems() for info. */
  359.  
  360. #pragma segment TheDoc
  361. Boolean    DialogAdjustMenuItems(WindowPtr window, short menuID)
  362. {
  363. #ifndef __MWERKS__
  364. #pragma unused (window)
  365. #endif
  366.  
  367.     if (menuID == mEdit)
  368.         CTEEditMenu(nil, mEdit, UnmapMItem(mEdit, kStdUndo), UnmapMItem(mEdit, kStdCut));
  369.  
  370.     return(false);
  371. }
  372.  
  373.  
  374.  
  375. /*****************************************************************************/
  376.  
  377.  
  378.  
  379. /* •• You don't call this.  DTS.Lib..framework does for appropriate document type(s). •• */
  380. /* See DoMenuItem() for info. */
  381.  
  382. #pragma segment TheDoc
  383. Boolean    DialogDoMenuItem(WindowPtr window, short menuID, short menuItem)
  384. {
  385. #ifndef __MWERKS__
  386. #pragma unused (window)
  387. #endif
  388.  
  389.     return(DoMenuCommand(menuID, menuItem));
  390. }
  391.  
  392.  
  393.  
  394.